GenerativeModelFutures

abstract class GenerativeModelFutures


Helper method for interacting with a GenerativeModel from Java.

See also
from

Summary

Public companion functions

GenerativeModelFutures

Public functions

abstract ListenableFuture<CountTokensResponse>
countTokens(vararg prompt: Content)

Counts the number of tokens used in a prompt.

abstract ListenableFuture<GenerateContentResponse>
generateContent(vararg prompt: Content)

Generates a response from the backend with the provided Content.

abstract Publisher<GenerateContentResponse>
generateContentStream(vararg prompt: Content)

Generates a streaming response from the backend with the provided Content.

abstract GenerativeModel

Returns the GenerativeModel instance that was used to create this object

abstract ChatFutures

Creates a chat instance which internally tracks the ongoing conversation with the model

abstract ChatFutures
startChat(history: List<Content>)

Creates a chat instance which internally tracks the ongoing conversation with the model

Public companion functions

Public functions

countTokens

abstract fun countTokens(vararg prompt: Content): ListenableFuture<CountTokensResponse>

Counts the number of tokens used in a prompt.

Parameters
vararg prompt: Content

A group of Content to count tokens of.

generateContent

abstract fun generateContent(vararg prompt: Content): ListenableFuture<GenerateContentResponse>

Generates a response from the backend with the provided Content.

Parameters
vararg prompt: Content

A group of Content to send to the model.

generateContentStream

abstract fun generateContentStream(vararg prompt: Content): Publisher<GenerateContentResponse>

Generates a streaming response from the backend with the provided Content.

Parameters
vararg prompt: Content

A group of Content to send to the model.

getGenerativeModel

abstract fun getGenerativeModel(): GenerativeModel

Returns the GenerativeModel instance that was used to create this object

startChat

abstract fun startChat(): ChatFutures

Creates a chat instance which internally tracks the ongoing conversation with the model

startChat

abstract fun startChat(history: List<Content>): ChatFutures

Creates a chat instance which internally tracks the ongoing conversation with the model

Parameters
history: List<Content>

an existing history of context to use as a starting point